<?php
include_once("inc/conn.php");
include_once("inc/function.php");
include_once("heheadmin/inc/config.php");

$sql='select game_table_prefix as p from game_config';
$res=$db->query($sql);
$i=$_GET['i']?:0;
$x=0;
while ($row=$db->fetch_array($res)){
    //if($i==$x++) {
        $sql = "DELETE FROM {$row[p]}_kg_users_tz WHERE TO_DAYS(NOW())-TO_DAYS(TIME)>0 ;";
        echo $sql."<br>";
        $sql="OPTIMIZE TABLE {$row[p]}_kg_users_tz";
        echo $sql."<br>";
        //$db->query($sql);
        //$db->query("OPTIMIZE TABLE {$row[p]}_kg_users_tz");
        //header('location:trun.php?i='.$x);
   // }
    //var_dump($row);

}


